package com.gitee.farmer.im.rabbit.receiver;

import com.gitee.farmer.im.core.FarmerSocket;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.context.annotation.Lazy;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * @author tech-farmer
 * @ClassName: Receiver
 * @Description: (这里用一句话描述这个类的作用)
 * @date 2022/2/24 16:59
 */
@Component
@EnableBinding(InputFarmerMessage.class)
@Slf4j
public class Receiver {

    @Autowired
    @Lazy
    private FarmerSocket socket;

    @StreamListener(InputFarmerMessage.input)
    public void receive(Message<String> message){
        final String payload = message.getPayload();
        socket.receive(payload);
    }
}
